Retrieve Lost Sidebar upon Widgets Activation

I played around with some widgets lately and once I activated a widget, then the whole sidebar disappear. This forced me to deactivate the widget and the sidebar will turn back to normal. Do you face the same? This is quite common in self-hosted WordPress due to variety of themes we used. This simple tweak might resolve it.

Most of the themes were designed based on WordPress 2.3 and below. It may or it may not support widget but most important is, the slight variance of php code used to call the loop is the main culprit.

Open your sidebar.php and locate the following code. You should find the code instantly since the file is pretty small. Depends on what theme you used, this is how it should look.

<?php
if ( function_exists('dynamic_sidebar') && dynamic_sidebar(1) ) :
else : ?>

The code is somehow outdated and doesn’t sufficient to call the loop. Replace the above codes with this:

<?php
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(1) ) :
else : ?>

This is how the final result should look.

widget_sidebar

Sample code used on the above image.

<h2>Blogs of Interest</h2>
<ul>
<?php get_links(-1, '<li>', '</li>', ' - '); ?>
</ul>
</li>
<?php
if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar(1) ) :
else : ?>
<li id="links">

Do you have other solution? Let me know how you resort yours.

digg reddit delicious stumbleupon technorati furl ma.gnolia
Does this post useful? Subscribe to RSS Feed for updates.
Posted on: July 3, 2008 | Under Tips & Tricks 
 

2 Responses to “Retrieve Lost Sidebar upon Widgets Activation”

  1. Tim on December 14th, 2009 12:57 pm

    I have had this problem several times and always gave up since I didn’t understand why it occurred. Thanks for the code!

  2. cultural issue on December 16th, 2009 8:21 pm

    That switches you out of Widget mode, so let go of the drag and now you have your widget on your desktop. It’s always on top of any other window, so that’s why you need screen real estate. If you decide you hate it, drag it back to Widget-land the same way: select it, hold the mouse, hit your Widget activate key, and let it drop back to its other widget friends.

Share your thoughts




Speak your mind